package com.hdl.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Objects;

/**
 * 类名 DataSourceProperties
 * 描述 TODO
 *
 * @author hedonglin
 * @version 1.0
 * @date 2020/6/18 14:16
 */
@ConfigurationProperties(prefix = "rpc.datasource")
@Component
public class DataSourceProperties implements Serializable {
    private String driverClassName;
    private String jdbcUrl;
    private String username;
    private String password;
    private Integer maxActive;
    private Integer maxIdle;

    public String getDriverClassName() {
        return driverClassName;
    }

    public void setDriverClassName(String driverClassName) {
        this.driverClassName = driverClassName;
    }

    public String getJdbcUrl() {
        return jdbcUrl;
    }

    public void setJdbcUrl(String jdbcUrl) {
        this.jdbcUrl = jdbcUrl;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getMaxActive() {
        return maxActive;
    }

    public void setMaxActive(Integer maxActive) {
        this.maxActive = maxActive;
    }

    public Integer getMaxIdle() {
        return maxIdle;
    }

    public void setMaxIdle(Integer maxIdle) {
        this.maxIdle = maxIdle;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        DataSourceProperties that = (DataSourceProperties) o;
        return Objects.equals(driverClassName, that.driverClassName) &&
                Objects.equals(jdbcUrl, that.jdbcUrl) &&
                Objects.equals(username, that.username) &&
                Objects.equals(password, that.password) &&
                Objects.equals(maxActive, that.maxActive) &&
                Objects.equals(maxIdle, that.maxIdle);
    }

    @Override
    public int hashCode() {
        return Objects.hash(driverClassName, jdbcUrl, username, password, maxActive, maxIdle);
    }


    @Override
    public String toString() {
        return "DataSourceProperties{" +
                "driverClassName='" + driverClassName + '\'' +
                ", jdbcUrl='" + jdbcUrl + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", maxActive=" + maxActive +
                ", maxIdle=" + maxIdle +
                '}';
    }
}
